package com.example.demo.timer;


import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeoutException;

/**
 * @desc: <br/>
 * @author: Jingbo Hu<br/>
 * @time：2021年06⽉16⽇<br/>
 * @version：v1.0.0<br>
 */
public class TimerTaskDemo {


    public static void main(String[] args) throws IOException, TimeoutException {

        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                System.out.println("Hello!Word!");
            }
        };

        Timer timer = new Timer();
        long delay = 2000;
        long intevalPeriod = 1 * 1000;
        timer.scheduleAtFixedRate(task, delay, intevalPeriod);

    }
}
